﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Seesmic.Sdp.Utils;

namespace Seesmic.HelloTipi.Controls
{
    public class HelloTipiMetaDataControl : MetadataControl
    { 
        public static DependencyProperty FamilleProperty = DependencyProperty.Register("Famille", typeof(string), typeof(HelloTipiMetaDataControl), null);
        public static DependencyProperty FamilleLinkProperty = DependencyProperty.Register("FamilleLink", typeof(Uri), typeof(HelloTipiMetaDataControl), null);
        public static DependencyProperty FamilleLinkVisibilityProperty = DependencyProperty.Register("FamilleLinkVisibility", typeof(Visibility), typeof(HelloTipiMetaDataControl), null);



        public HelloTipiMetaDataControl() : base()
        {
            DefaultStyleKey = typeof(HelloTipiMetaDataControl);
        }

        public string Famille
        {
            get
            {
                return (string)base.GetValue(FamilleProperty);
            }
            set
            {
                base.SetValue(FamilleProperty, value);
            }
        }

        public Uri FamilleLink
        {
            get
            {
                return (Uri)base.GetValue(FamilleLinkProperty);
            }
            set
            {
                base.SetValue(FamilleLinkProperty, value);
            }
        }

        public Visibility FamilleLinkVisibility
        {
            get
            {
                return (Visibility)base.GetValue(FamilleLinkVisibilityProperty);
            }
            set
            {
                base.SetValue(FamilleLinkVisibilityProperty, value);
            }
        }
       
        new public static string DateTimeToFriendlyString(DateTime t, bool isUniversalTime)
        {
            DateTime time = isUniversalTime ? DateTime.Now.ToUniversalTime() : DateTime.Now;
            if (t > time)
            {
                return "dans le futur";
            }
            if (t.AddSeconds(10.0) > time)
            {
                return "à l'instant";
            }
            if (t.AddSeconds(60.0) > time)
            {
                int num = (int)(TimeSpan.FromTicks(time.Ticks).TotalSeconds - TimeSpan.FromTicks(t.Ticks).TotalSeconds);
                return ("Il y a " + num.ToString() + ((num == 1) ? " seconde" : " secondes"));
            }
            if (t.AddMinutes(60.0) > time)
            {
                int num2 = (int)(TimeSpan.FromTicks(time.Ticks).TotalMinutes - TimeSpan.FromTicks(t.Ticks).TotalMinutes);
                return ("Il y a " + num2.ToString() + ((num2 == 1) ? " minute" : " minutes"));
            }
            if (t.AddHours(24.0) > time)
            {
                int num3 = (int)(TimeSpan.FromTicks(time.Ticks).TotalHours - TimeSpan.FromTicks(t.Ticks).TotalHours);
                return ("Il y a " + num3.ToString() + ((num3 == 1) ? " heure" : " heures"));
            }
            if (t.AddDays(5.0) > time)
            {
                int num4 = (int)(TimeSpan.FromTicks(time.Ticks).TotalDays - TimeSpan.FromTicks(t.Ticks).TotalDays);
                return ("Il y a " + num4.ToString() + ((num4 == 1) ? " jour" : " jours"));
            }
            return t.ToString("d MMM yyyy");
        }

 

 

    }
}
